<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of settings
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Email_template extends CI_Controller {

    //put your code here


    function email_template() {
        parent :: __construct();
        $this->load->model('settings_model');
        $this->commoncall->check_admin_login();
    }

    function index() {
        $data['template'] = $this->settings_model->get_template();
        $this->load->view('admin/admin_email_template', $data);
    }

    function get_tempalate($templateID) {
        $data['template_row']=$this->settings_model->get_template_by_id($templateID);
        $this->load->view('admin/admin_email_template', $data);
    }

    function update_template() {
        if ($this->input->post('update_template')) {
            $this->form_validation->set_rules('templatedescription', 'templatedescription','required|xss_clean');
            $this->form_validation->set_rules('template_id', 'template_id','|required|xss_clean');
            $id = trim($this->input->post('template_id'));
            $template_description = trim($this->input->post('templatedescription'));
            if ($this->form_validation->run()) {
                $data = array('description' => $template_description);
                $this->db->where('id', $id);
                $this->db->update('email_template', $data);
                redirect('admin/email_template/get_tempalate/'. $id);
            }
        }
        redirect('admin/email_template/get_tempalate/'. $id);
    }

}

?>